/*
 * @Author: CQJ
 * @Date: 2022-09-16 14:43:36
 * @LastEditors: CQJ
 * @LastEditTime: 2022-09-16 22:51:26
 * @Description:
 */
import { reactive } from 'vue'
import type { ImageTypeData } from '@/types/system/systemConfig'
interface ConfigState {
  activeKey: string
}

// 状态管理
export const configState = reactive<ConfigState>({
  activeKey: '1'
})
const validateVolume = (rule: any, value: any, callback: any) => {
  const maxSize = 104857600
  if (!value) {
    callback(new Error('请输入上传图片体积'))
  } else if (value > maxSize) {
    callback(new Error('图片大小不能超过100M'))
  } else {
    callback()
  }
}
export const configRules = reactive({
  //基础配置
  checkCode: [{ required: true, message: '请输入站长校验码' }],
  //图片设置
  // volume: [{ required: true, message: '请输入上传图片体积' }],
  volume: [{ required: true, validator: validateVolume, trigger: 'blur' }],
  img_type: [{ required: true, message: '请选择上传图片类型' }],
  // douban_movie_addr: [{ required: true, message: '请输入豆瓣影片接口' }],
  // douban_person_addr: [{ required: true, message: '请输入豆瓣影人接口' }],
  movie_cover: [{ required: true, message: '请输入视频封面域名' }],
  atlas_cover: [{ required: true, message: '请输入图集封面域名' }],
  article_cover: [{ required: true, message: '请输入文章封面域名' }],
  person_cover: [{ required: true, message: '请输入演员封面域名' }],
  atlas_content_cover: [{ required: true, message: '请输入图集内容域名' }],
  adv_cover: [{ required: true, message: '请输入广告图片域名' }]
  // baiduFilmAddress: [{ required: true, message: '请输入百度百科影片接口地址' }],
  // wikiFilmAddress: [{ required: true, message: '请输入维基百科影片接口地址' }]
})
export const IMAGE_DATA: ImageTypeData[] = [
  { value: 0, label: 'jpg&jpeg' },
  { value: 1, label: 'png' },
  { value: 2, label: 'bmp' },
  { value: 3, label: 'webp' },
  { value: 4, label: 'gif' }
]
export const IMAGE_TYPE: Record<number, any> = {
  0: 'jpg&jpeg',
  1: 'png',
  2: 'bmp',
  3: 'webp',
  4: 'gif'
}
